import json
from re import match

import requests
from wheel.macosx_libfile import swap32

url = 'https://open-api.coinank.com'
headers = {
    "apikey": "1a146c33dfdb4c0e8fcde2864c23b8ed"
}

# # 贪婪恐惧指数(Plan1) 无参数
# response1 = requests.get(url + '/api/indicator/getCnnEntity?baseCoin=asfasdfasfasas', headers=headers)
# print(response1.text)

# 交易所实时多空比(Plan1)
# interval：5m,15m,30m,1h,2h,4h,6h,8h,12h,1d
# # # baseCoin:BTC,ETH
response2 = requests.get(url + '/api/longshort/realtimeAll?baseCoin=BTC&interval=5m', headers=headers)
print(response2.text)

# # 实时资金费率
# # current：实时,day:1日,week：1周,month：1月,year ：1年
# response3 = requests.get(url + "/api/fundingRate/current?type=year", headers=headers)
# print(response3.text)
#
# 实时持仓（币种）(Plan1)
# baseCoin：BTC,ETH
# response4 = requests.get(url + "/api/tickers/topOIByEx?baseCoin=BTC", headers=headers)
# print(response4.text)
#
# # 特色指标数据(Plan1)
# # 1.彩虹图V2：bitcoin-rainbow-v2
# # 2.一年+Hold波：/charts/1-year-hodl-wave/
# # 3.hold波：/charts/hodl-waves/
# # 4.MVRV Z-Score ：/charts/mvrv-zscore/
# # 5.未实现净损益 (NUPL)：/charts/relative-unrealized-prof/
# # 6.比特币价格预测：/charts/bitcoin-price-prediction/
# # 7.准备金风险：/charts/reserve-risk/
# # 8.RHODL 比率：/charts/rhodl-ratio/
# # 9.鲸影：/charts/whale-shadows/
# response5 = requests.get(url + "/api/indicator/index/charts?type=bitcoin-rainbow-v2", headers=headers)
# print(response5.text)

# # 将JSON响应保存到文件
# with open('bitcoin_rainbow_data.json', 'w', encoding='utf-8') as f:
#     json.dump(response5.json(), f, ensure_ascii=False, indent=4)
#
# print("数据已成功保存到 bitcoin_rainbow_data.json 文件")
#
# # 支持的币种(Plan1) productType:spot/swap
# response6 = requests.get(url + "/api/baseCoin/list?productType=spot", headers=headers)
# print(response6.text)
#
# # 支持的交易对 exchange=Binance&productType=SWAP
# response7 = requests.get(url + "/api/baseCoin/symbols?exchange=Binance&productType=SWAP", headers=headers)
# print(response7.text)

# 山寨指数(Plan1)
# response8 = requests.get(url + "/api/indicator/getAltcoinSeason", headers=headers)
# print(response8.text)

# response9 = requests.get(url + "/api/indicator/getMarketCapRank?symbol=BTC", headers=headers)
# print(response9.text)

# btc市值
# response10 = requests.get(url + "/api/instruments/getCoinMarketCap?baseCoin=BTC", headers=headers)
# print(response10.text)
